(function($, doc) {
	$.init();
	var user = app.getState();
	//$.getJSON(apiurl + 'token/getwalletlist?uid=' + user.user_id, function(res) {
	//console.log(JSON.stringify(res));
	var ethWallet = ethscan.getWallet('eth');
	var btcWallet = ethscan.getWallet('btc');
	var eosWallet = ethscan.getWallet('eos');
	doc.getElementById('etharea').innerHTML = template("wallet-template", {
		data: ethWallet['list'],
		def : ethWallet.address,
		etype : 'eth'
	});

	doc.getElementById('btcarea').innerHTML = template("wallet-template", {
		data: btcWallet['list'],
		def : btcWallet.address,
		etype : 'btc'
	});
	doc.getElementById('eosarea').innerHTML = template("wallet-template", {
		data: eosWallet['list'],
		def : eosWallet.address,
		etype : 'eos'
	});
	$('.mui-card').on('tap', 'li', function() {
		var etype = this.getAttribute('data-etype');
		var address = this.getAttribute('data-id');
		//var obj = res[etype][address];
		var el = doc.getElementById(address);
		if(el.checked) {
			//console.log(el.checked);
			//el.setAttribute('checked', true);
			return;
		}
		if(etype == 'eth') {
			var wallet = ethWallet;
		} else if(etype == 'btc'){
			var wallet = btcWallet;
		} else if(etype == 'eos'){
			var wallet = eosWallet;
		}
		//console.log(JSON.stringify(wallet));
		var list = wallet['list'];
		var res = list[address];
		for(var p in res) {
			wallet[p] = res[p];
		}
		//console.log(JSON.stringify(wallet));
		//return;
		ethscan.setWallet(wallet,etype);
		$.toast('设置成功！');
	});

	//});
}(mui, document));